home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan
/
Opus 5 - Magellan.iso
/
Extras
/
Install_3.3
/
ARexx
/
Install_GetID.dopus5
< prev
next >
Wrap
Text File
|
1997-05-09
|
5KB
|
189 lines
/* $VER: Install_GetID.dopus5 3.1 (09.05.97) © Frédéric Steinfels
*/
signal on BREAK_C
signal on BREAK_D
signal on BREAK_E
signal on BREAK_F
signal on HALT
signal on IOERR
signal on SYNTAX
signal on FAILURE
options failat 21
options results
parse arg arguments
ProgramName = "Install_GetID.dopus5";
ArgsTemplate = "PORT/A,MNPORT/A,MYPORT/A,MYID/A,WRITECOM/S,LPATH/A"
lf='0a'x
if strip(arguments) = '?' then do
Call WriteCh(STDOUT, ArgsTemplate || ': ')
pull arguments
end; else nop
if ~ReadArgs(arguments,ArgsTemplate) then do
say Fault(RC,ProgramName)
exit 10
end; else nop
drop arguments
catalog=opencatalog('Install.dopus5.catalog','english',0)
address value PORT
inlocpr='DOpus5:System/Install_Locale.prefs'
if ~open(lp,inlocpr,'READ') then do
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(15,'Unable to open') inlocpr || '"' GetCatStr(0,'Abort')
Call CleanUP
exit
end
junk=readln(lp)
month=1
do while month < 13
cnt=0
do while cnt<9
d.month.cnt=readln(lp)
cnt=cnt+1
end
month=month+1
end
d.tr=readln(lp)
Call Close(lp)
MYPORTH=openport(MYPORT)
do until CMD='0'
call waitpkt(MYPORT)
Packet=getpkt(MYPORT)
if Packet ~= null() then do
ln = getarg(Packet,0)
ID=substr(ln,1,1)
CMD=substr(ln,2,1)
ARG=substr(ln,3)
call CheckArg
IF ID=0 & CMD=1 THEN DO
vdate=0
q=0
com=''
parse var arg path '0a'x name '0a'x numf '0a'x fdate '0a'x note
file=makepath(makepath(lpath,path),name)
if open(test,file,'READ') then do
Call Close(test)
com=crc32(file)
com=com || copies('0',8-length(d2x(fdate))) || d2x(fdate)
ADDRESS COMMAND 'Failat 21' || lf || 'version >T:VER' || MYPORT 'FULL FILE "' || file || '"' || lf || 'If Warn' || lf || 'Delete T:VER' || MYPORT || lf || 'EndIf'
if open(f,'T:VER'||MYPORT,'READ') then do
do while ~EOF(f)
com=com readln(f)
end
Call Close(f)
com=TRANSLATE(com,' ','a0'x)
rest=substr(com,10)
year=0
do while year=0 & POS('(',rest)<POS(')',rest) & POS('(',rest)>0
parse var rest . '(' tdate ')' rest
bdate=tdate
month=1
do while month < 13 & year=0
if length(tdate)=d.month.0 then Call ParseLocDate
month=month+1
end
month=month-1
end
if year~=0 then do
day=strip(day,'L')
day=copies('0',2-length(day)) || day
month=copies('0',2-length(month)) || month
tdate=day || '.' || month || '.' || year
vdate=DATE('i',year || month || day,'s')
q=pos(bdate,com)
l=length(bdate)
com=delstr(com,q,l)
com=insert(tdate,com,q-1)
end
end
do while POS(' ',com) ~= 0
com=DELSTR(com,POS(' ',com),1)
end
com=strip(com,'T')
if note~='' then com = com || '¸' note
if length(com)>79 then com=left(com,79)
if WRITECOM=1 then do
rv=setcomment(file,com)
end
end
dopus send MNPORT MYID || 1 || name || lf || numf || lf || com
end
end
end
Call CleanUP
exit
ParseLocDate:
if d.month.1~=0 then if substr(tdate,d.month.1,1)~=d.tr then return
if d.month.2~=0 then if substr(tdate,d.month.2,1)~=d.tr then return
if SUBSTR(tdate,d.month.6,d.month.7)~=d.month.8 then return
day=substr(tdate,d.month.3,2)
year=substr(tdate,d.month.4,2)+1900
if year<78 then year=year+100
return
CheckArg:
IF DATATYPE(ID)~='NUM' | DATATYPE(CMD)~='NUM' THEN Call CheckArgFail
IF ID~=0 THEN Call CheckArgFail
IF CMD>1 THEN Call CheckArgFail
RETURN
CheckArgFail:
address value PORT
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(52,'Invalid packet received') || lf || 'ID=' || ID || lf || 'CMD=' || CMD || lf || 'ARG=' || ARG || '"' GetCatStr(0,'Abort')
Call CleanUP
exit
ERROR:
HALT:
IOERR:
SYNTAX:
IF RC ~= 0 THEN DO
line=sigl
text=errortext(rc)
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || text || lf || GetCatStr(19,'Line') line || '"' GetCatStr(0,'Abort')
END
else do
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || '"' GetCatStr(0,'Abort')
end
BREAK_C:
BREAK_D:
BREAK_E:
BREAK_F:
Call CleanUP
exit
CleanUp:
dopus send MNPORT MYID || 0
if POS(MYPORT,SHOW('p'))~=0 then do
Call FORBID()
Call ClosePort(MYPORTH)
Call PERMIT()
end
Call CloseCatalog(catalog)
return
getcatstr: /* Thank you for this procedure, Edmund */
parse arg msgno,msgstring
if catalog~=0 then
msgstring=getcatalogstr(catalog,msgno,msgstring)
do i=3 to arg()
parse var msgstring fore '%s' aft
msgstring=fore||arg(i)||aft
end
return msgstring